﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace StockholmsStad.Windows.UI.Infrastructure.Controls
{
    /// <summary>
    /// Interaction logic for DatePickerPopup.xaml
    /// </summary>
    public partial class DatePickerPopup : UserControl
    {
        public event RoutedEventHandler SelectedDateChanged;

        public DatePickerPopup()
        {
            InitializeComponent();

            popupControl.StaysOpen = false;
        }

        private void MonthCalendar_DateSelectionChanged(object sender, Microsoft.Samples.KMoore.WPFSamples.DateControls.DateSelectionChangedEventArgs e)
        {
            if (SelectedDateChanged != null)
                SelectedDateChanged(this, new RoutedEventArgs());

            popupControl.IsOpen = false;
        }

        public DateTime? SelectedDate
        {
            get { return dateControl.SelectedDate; }
            set { dateControl.SelectedDate = value; }
        }

        private void openPopup_Click(object sender, MouseButtonEventArgs e)
        {
            popupControl.IsOpen = true;
        }
    }
}
